﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using Business.entidades;
using System.Reflection;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;

namespace Business.dao.conf
{

    public class QuestaoMAP : EntityTypeConfiguration<Questao>
    {
        public QuestaoMAP()
        {
            ToTable("Questao", Constantes.DEFAULT_SCHEMA);
            HasKey(t => t.QuestaoId);
            Property(t => t.QuestaoId).HasColumnName("questaoId")
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            Property(t => t.Descricao).HasColumnName("descricao");
            HasOptional(t => t.Classificacao)
                .WithMany(t => t.Questoes)
                .Map(mc => mc.MapKey("classificadorId"))
                .WillCascadeOnDelete(true);
        }
    }

    public class ClassificadorMAP : EntityTypeConfiguration<Classificador>
    {
        public ClassificadorMAP()
        {
            ToTable("Classificador", Constantes.DEFAULT_SCHEMA);
            HasKey(t => t.ClassificadorId);
            Property(t => t.ClassificadorId).HasColumnName("classificadorId")
                    .IsRequired()
                    .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            Property(t => t.Descricao).HasColumnName("descricao");
        }
    }

}

